#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const LL MOD=998244353;
const LL MAXN=1e8+7;
LL prime[MAXN], p_cnt;
bool is_prime[MAXN];
int mu[MAXN];
void Init() {
	memset(is_prime, 1, sizeof(is_prime));
	p_cnt=0;
	mu[1]=1;
	for (LL i=2; i<MAXN; ++i) {
		if (is_prime[i]) {
			prime[p_cnt++]=i;
			mu[i]=-1;
		}
		for (LL j=0; j<p_cnt&&prime[j]*i<MAXN; ++j) {
			is_prime[i*prime[j]]=false;
			if (i%prime[j]==0) {
				mu[i*prime[j]]=0;
				break;
			}
			else {
				mu[i*prime[j]]=-mu[i];
			}
		}
	}
}
LL GetAns(LL n) {
	LL t1=n;
	LL t2=n+1;
	LL t3=2*n+1;
	if (t1%2==0) t1=t1/2;
	else t2=t2/2;
	if (t1%3==0) t1=t1/3;
	else if (t2%3==0) t2=t2/3;
	else t3=t3/3;
	return (t1*t2%MOD)*t3%MOD; 
}
int main() {
	Init();
	#ifdef hai
	freopen("in.txt", "r", stdin);
	#endif
	LL T, ask, res, t;
	cin>>T;
	while (T--) {
		cin>>ask;
		LL len=sqrt(ask)+3;
		res=0;
		for (LL i=1; i<len&&i<ask; ++i) {
			if (ask%i==0) {
				t=mu[i]*i*i%MOD;
				t=t*GetAns(ask/i)%MOD;
				res=(res+t)%MOD;
			}
		}
		res=(res+mu[ask]*ask*ask%MOD)%MOD;
		if (res<0) res+=MOD;
		cout<<res<<endl; 
	}
	return 0;
}
